{% extends "participants/participantsbase.html" %}

{% block content %}
    <div class="form_container indent">
	<h1>Edit Profile</h1>
	
    <form action="{{ file_data.target }}" method="post" enctype="multipart/form-data">{% csrf_token %}{{ file_data.data }}
		<div><input type="hidden" name="next" value="{{ request.path }}" /></div>
    {# Floating Save Button #}
    <button type="submit" class="button SaveButton" name="Save" value="SaveEdit" style="position: fixed; bottom: 0px; right: 0px; z-index: 5;" title="Save and Continue Editing"><a>Save</a></button>
    
    {# Title #}
    <table border="0">
	<tr>
	    {% load files %}
	    {% get_file_list for user as Files %}
	    {% if Files.avatar or course.allow_student_avatar_change %}
		<th>Avatar:</th>
	    {% endif %}
	    {% if Files.avatar %}
		<td><img src="{{Files.avatar.url}}"></td>
	    {% endif %}
	{% if course.allow_student_avatar_change %}
	    {% get_file_form for user as file_form %}
	    <td>
		{% for field in file_form.hidden_fields %}
		    <div>{{ field }}</div>
		{% endfor %}
		<div><input type="hidden" name="title" id="id_title" value="avatar" /></div>
		<div><input type="hidden" name="description" id="id_description" value="" /></div>
		{% if file_form.file.errors %}{{ file_form.file.errors }}{% endif %}
		<p {% if file_form.file.errors %} class="error"{% endif %}>{{file_form.file}}</p>
		{% if file_form.honeypot.errors %}{{ file_form.honeypot.errors }}{% endif %}
		<p style="display:none;" {% if file_form.honeypot.errors %} class="error"{% endif %}>{{file_form.honeypot.label_tag}} {{file_form.honeypot}}</p>
	    </td>
	{% endif %}
	</tr>
    
	{% if user_form %}{{user_form.as_table}}
	{% else %}
	<tr><th>First name:</th><td>{{user.first_name}}</td></tr>
	<tr><th>Last name:</th><td>{{user.last_name}}</td></tr>
	<tr><th>E-mail address:</th><td>{{user.email}}</td></tr>
	{% endif %}
    {% for item,addition_form in Additions %}
	<tr><th>{{item.name}}:</th><td>{{addition_form.value}}</td><td>{{addition_form.value.errors}}{{item.description}}</tr>
    {% endfor %}
    <tr>
	<td colspan="4" class="Buttons">
	    <button type="submit" class="button SaveButton floatleft" name="Save" value="SaveEdit" title="Save and Continue Editing">Save and Continue</button>
	    <button type="submit" class="button SaveButton floatleft" name="Save" value="SaveReturn" title="Save and Return to Profile">Save and Return</button>
	    <a class="button SaveButton floatleft" href="{% course_url apps.participants.views.view_profile %}">Cancel</a>
	</td>
    </tr>
    </table>
    </form>
    </div>
{% endblock content %}